package org.sfx.control

import org.sfx.rich.Enrich._

import javafx.scene.control.Skin
import javafx.scene.Node
import javafx.scene.Group
import javafx.scene.control.Label
import javafx.scene.shape.Path
import javafx.scene.shape.MoveTo
import javafx.scene.shape.LineTo
import javafx.scene.shape.ClosePath
import javafx.scene.layout.StackPane
import javafx.scene.layout.HBox
import javafx.scene.layout.VBox

import scala.collection.JavaConverters._

class TabPaneSkin(val control: TabPane) extends Skin[TabPane] {
  val rootNode = new Group()
  val moo = List()
  val tabPaneArea = new VBox()
  val contentArea = new StackPane()
  val tabHeader = new HBox()
  
  tabPaneArea.getChildren.addAll(tabHeader, contentArea)
  this.rootNode.getChildren.addAll(tabPaneArea)
  
  getSkinnable.tabs.translateInto(tabHeader.getChildren) { new TabHandle(_) }
  getSkinnable.tabs.translateInto(contentArea.getChildren) { new TabContent(_) }
  
  def getControl(): TabPane = control
  def getNode(): Node = rootNode
  def dispose(): Unit = {}

  override def getSkinnable(): TabPane = control
  
  class TabHeaderArea extends StackPane {
    val headersRegion = new StackPane() {
      protected override def computePrefWidth(paramWidth: Double): Double = {
        // TODO: Compute tab header area width
        super.computePrefWidth(paramWidth)
      }
      
      protected override def computePrefHeight(paramHeight: Double): Double = {
        // TODO: Compute tab header area height
        super.computePrefHeight(paramHeight)
      }

      protected override def layoutChildren(): Unit = {
        // TODO: layout tab header children
        super.layoutChildren()
      }
    }
  }
}
